define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'monitor/recipient/index',
                    add_url: 'monitor/recipient/add',                        
                    edit_url: 'monitor/recipient/edit',
                    del_url: 'monitor/recipient/del',
                    multi_url: '',
                    table: '',                    
                }
            });

            var table = $("#table");
            var mail_group = Config.group;
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,                
                sortName: 'ops_mail.id',
                search: false,
                showToggle: false,
                showColumns: false,
                showExport:false,
                columns: [
                    [
                    {checkbox: true},
                    {field:"ops_mail.id",title: __('ID'),formatter:function(value,row,index){
                        return row.id;        
                    }},                   
                    {field: 'number',operate:'LIKE',placeholder: __('模糊查询'), title: __('邮箱号'),formatter:function(value,row,index){
                        if(!value){
                            return "";
                        }else{
                            return value;
                        }           
                    }},
                    {field: 'mail_group_ids', title: __('邮件组'),searchList:mail_group,operate:'LIKE %...%',formatter:function(value,row,index){
                        return row.group_name;
                    }},
                    {field: "ops_mail.createtime",title: __('创建时间'),operate:'RANGE',addclass:'datetimerange',formatter:function(value,row,index){
                        return row.createtime;     
                    }},
                    {field: 'datatime',title: __('更新时间'),operate:'RANGE',addclass:'datetimerange',},                     
                    {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},                        
                    ]
                ],
                // commonSearch: false,
            });

            

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        get: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});